package main

import "fmt"

func main() {
	data := []string{"one", "", "three"}
	data = nonempty(data)
	// fmt.Printf("%q\n", nonempty(data))
	fmt.Printf("%q\n", nonempty2(data))
	fmt.Printf("%q", data)
}

func nonempty(strs []string) []string {
	i := 0
	for _, s := range strs {
		if s != "" {
			strs[i] = s
			i++
		}
	}
	return strs[:i]
}

func nonempty2(strs []string) []string {
	out := strs[:0]
	for _, s := range strs {
		if s != "" {
			out = append(out, s)
		}
	}
	return out
}
